package com.bsoft.gol.hbs.service.impl;

import com.bsoft.gol.hbs.bean.Vo.ModuleConfigVo;
import com.bsoft.gol.hbs.bean.request.PropertyConfigRequest;
import com.bsoft.gol.hbs.dao.BaseCopywriterConfigDAO;
import com.bsoft.gol.hbs.dao.BaseModuleConfigDAO;
import com.bsoft.gol.hbs.dao.BasePropertyConfigDAO;
import com.bsoft.gol.hbs.service.BaseLevelConfigService;
import com.bsoft.gol.hbs.utils.CommonUtils;
import com.google.common.collect.ImmutableMap;
import ctd.account.UserRoleToken;
import ctd.app.support.Module;
import ctd.controller.exception.ControllerException;
import ctd.dictionary.Dictionary;
import ctd.dictionary.DictionaryItem;
import ctd.dictionary.SliceTypes;
import ctd.dictionary.controller.DictionaryController;
import ctd.module.controller.ModuleController;
import ctd.net.rpc.util.ServiceAdapter;
import ctd.parameter.Parameter;
import ctd.parameter.controller.ParameterController;
import ctd.parameter.entity.ParameterEntity;
import ctd.spring.boot.annotation.RpcAccess;
import ctd.spring.boot.annotation.SsdevService;
import ctd.util.AppContextHolder;
import ctd.util.JSONUtils;
import ctd.util.annotation.RpcService;
import hcn.base.BaseCopywriterConfig;
import hcn.base.BaseModuleConfig;
import hcn.base.BasePropertyConfig;
import hcn.base.Organization;
import hcn.base.Service;
import hcn.base.ServiceProperty;
import hcn.bean.OrgBean;
import hcn.util.RpcUserToken;
import hcn.util.validation.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.atag.core.model.bbp.ParameterVO;
import org.atag.core.model.common.ObjectIdDTO;
import org.atag.core.model.common.PropertyCodeDTO;
import org.atag.util.bbp.ParamUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import pcn.bean.consultation.CopywriterQo;
import service.rpc.OrganizationInfoIntf;
import service.rpc.ServiceOpenIntf;
import ssdev.bbp.parameter.IParamConfigService;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
 * @Author yaosj
 * 系统基础功能配置类
 */
@SsdevService("baseLevelConfigService")
public class BaseLevelConfigServiceImpl implements BaseLevelConfigService {

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseLevelConfigServiceImpl.class);

    @Autowired
    private BaseModuleConfigDAO baseModuleConfigDAO;
    @Autowired
    private BasePropertyConfigDAO basePropertyConfigDAO;
    @Autowired
    private OrganizationInfoIntf organizationInfoIntf;
    @Autowired
    private BaseCopywriterConfigDAO baseCopywriterConfigDAO;
    @Autowired
    private ServiceOpenIntf serviceOpenIntf;
    @Value("${gol.app.code:}")
    private String golAppCode;

    /**
     * 保存功能配置
     *
     * @param baseModuleConfig
     * @throws ControllerException
     */
    @Override
    public void saveBaseModuleConfig(BaseModuleConfig baseModuleConfig) throws ControllerException {
        if (StringUtils.isEmpty(baseModuleConfig.getModuleId()) || StringUtils.isEmpty(baseModuleConfig.getObjectId())) {
            throw new ControllerException(0, "参数不能为空:moduleId,objectId");
        }
        String objectName = "";
        switch (baseModuleConfig.getLevel()) {
            case "1":
                objectName = "健康城市管理平台";
                break;
            case "2":
                objectName = "健康城市";
                break;

            case "3":
                Organization organization = organizationInfoIntf.getOrgDetailByOrgId(baseModuleConfig.getObjectId());
                objectName = organization != null ? organization.getFullName() : "";
                break;
        }
        String moduleName = "";
        switch (baseModuleConfig.getModuleId()) {
            case "01":
                moduleName = "家医签约";
                break;
            case "02":
                moduleName = "计费规则";
                break;
            case "03":
                moduleName = "病历复印";
                break;
            case "04":
                moduleName = "在线问诊";
                break;

        }
        BaseModuleConfig baseModuleConfig_exist = baseModuleConfigDAO.getModuleConfigByModuleId(baseModuleConfig.getModuleId(), baseModuleConfig.getObjectId());
        if (baseModuleConfig_exist != null) {
            baseModuleConfig_exist.setModuleName(moduleName);
            baseModuleConfig_exist.setObjectName(objectName);
            baseModuleConfig_exist.setObjectId(baseModuleConfig.getObjectId());
            baseModuleConfig_exist.setLevel(baseModuleConfig.getLevel());
            baseModuleConfigDAO.update(baseModuleConfig_exist);
        } else {
            baseModuleConfig.setModuleName(moduleName);
            baseModuleConfig.setObjectName(objectName);
            baseModuleConfigDAO.save(baseModuleConfig);
        }
    }

    /**
     * 获取功能配置列表
     *
     * @param objectId 来源id(租户id或机构id)
     * @return
     */
    @Override
    public List<BaseModuleConfig> queryAllModuleConfig(String objectId, String moduleId) throws ControllerException {
        //如果机构存在，那么传进来的参数objectId就是机构级，机构id
        String level = "3";
        String objectType = "org";
        Organization organization = organizationInfoIntf.getOrgDetailByOrgId(objectId);
        //如果机构不存在，那么传进来的参数objectId就是租户级，租户id
        if (null == organization) {
            objectType = "nxqrmyy";
            level = "2";
        }
        List<BaseModuleConfig> list = new ArrayList<BaseModuleConfig>();
        if (StringUtils.isEmpty(moduleId)) {
            if ("nxqrmyy".equals(objectType)) {
                list = baseModuleConfigDAO.queryModuleConfigByParams(level, null, null);
            } else {
                list = baseModuleConfigDAO.queryModuleConfigByParams(level, null, objectId);
            }
        } else {
            if ("nxqrmyy".equals(objectType)) {
                list = baseModuleConfigDAO.queryModuleConfigByParams(level, moduleId, null);
            } else {
                list = baseModuleConfigDAO.queryModuleConfigByParams(level, moduleId, objectId);
            }
        }
        String finalLevel = level;
        list.forEach(t -> {
            if (StringUtils.isEmpty(t.getLevel())) {
                t.setLevel(finalLevel);
            }
        });
        return list;
    }


    /**
     * 初始化功能配置
     */
    @Override
    public void initBaseModuleConfig(String orgId) throws ControllerException {
        List<Organization> organizations = null;
        if(CommonUtils.isNotEmpty(orgId)){
            Organization organization = organizationInfoIntf.getOrgDetailByOrgId(orgId);
            if(null != organization){
                organizations = new ArrayList<>();
                organizations.add(organization);
            }
        }else {
            organizations = organizationInfoIntf.findAllOrgMain(0, 0);
        }

        for (Organization organization : organizations) {
            Dictionary moduleDic = DictionaryController.instance().get("hcn.base.dictionary.baseModule");
            List<DictionaryItem> moduleItems = moduleDic.getSlice(null, SliceTypes.ALL, null);
            String moduleId = "";
            String moduleName = "";
            for (DictionaryItem moduleItem : moduleItems) {
                moduleId = moduleItem.getKey();
                moduleName = moduleItem.getText();
                BaseModuleConfig baseModuleConfig = baseModuleConfigDAO.getModuleConfigByModuleIdAndObjectId(moduleId, organization.getOrgId());
                if (baseModuleConfig == null) {
                    BaseModuleConfig b = new BaseModuleConfig();
                    b.setLevel("3");
                    b.setModuleId(moduleId);
                    b.setModuleName(moduleName);
                    b.setObjectId(organization.getOrgId());
                    b.setObjectName(organization.getFullName());
                    baseModuleConfigDAO.save(b);
                } else {
                    LOGGER.info("初始化功能配置 已经存在的过滤机构:" + JSONUtils.toString(baseModuleConfig));
                    //初始化参数配置 已经存在的过滤
                    continue;
                }
            }
            for (DictionaryItem moduleItem : moduleItems) {
                moduleId = moduleItem.getKey();
                moduleName = moduleItem.getText();
                BaseModuleConfig baseModuleConfig = baseModuleConfigDAO.getModuleConfigByModuleIdAndObjectId(moduleId, RpcUserToken.getTenantId());
                if (baseModuleConfig == null) {
                    BaseModuleConfig b = new BaseModuleConfig();
                    b.setLevel("2");
                    b.setModuleId(moduleId);
                    b.setModuleName(moduleName);
                    b.setObjectId(RpcUserToken.getTenantId());
                    b.setObjectName("健康城市");
                    baseModuleConfigDAO.save(b);
                }
            }
        }
    }

    //病历复印初始化
    @Override
    public void initBl() throws ControllerException {
        List<Organization> organizations = organizationInfoIntf.findAllOrgMain(1, 20000);
        for (Organization organization : organizations) {
            BaseModuleConfig baseModuleConfig = baseModuleConfigDAO.getModuleConfigByModuleIdAndObjectId("03", organization.getOrgId());
            if (baseModuleConfig == null) {
                BaseModuleConfig b = new BaseModuleConfig();
                b.setLevel("3");
                b.setModuleId("03");
                b.setModuleName("病历复印");
                b.setObjectId(organization.getOrgId());
                b.setObjectName(organization.getFullName());
                baseModuleConfigDAO.save(b);
            }
        }
    }


    /**
     * 根据条件获取系统参数
     *
     * @return
     */
    @RpcService
    public String getPropertyConfigByPropertyCodeBBP(String propertyCode, String objectId) throws ControllerException {
        try {
            if (StringUtil.isEmpty(propertyCode)) {
                throw new ControllerException("系统参数编码不能为空");
            }
            String moduleCode = propertyCode.substring(0, 4);
            Module module = ModuleController.instance().getModuleByCode("bsoft-jkt");
            Module module1 = ModuleController.instance().getModuleByCode("ca.org");
            if (module == null || StringUtils.isEmpty(module.getId())) {
                throw new ControllerException("系统参数对应的模块为空");
            }
            if (StringUtil.isEmpty(objectId)) {
                Parameter parameter = ParameterController.instance().get(propertyCode, module.getId());
                if (parameter == null) {
                    return null;
                }
                return parameter.getDefaultValue();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    @RpcService
    public BasePropertyConfig getBasePropertyConfig(String propertyCode, String orgId) throws ControllerException {
        try {
            BasePropertyConfig basePropertyConfig = new BasePropertyConfig();
            if (StringUtil.isEmpty(propertyCode)) {
                throw new ControllerException("系统参数编码不能为空");
            }
            Parameter parameter = null;
            if (StringUtils.isEmpty(orgId)) {
                parameter = ParameterController.instance().get(propertyCode, null);
                basePropertyConfig.setPropertyCode(propertyCode);
                basePropertyConfig.setPropertyData(parameter.getDefaultValue());
                basePropertyConfig.setUnit(parameter.getDes());
                return basePropertyConfig;
            }

            ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();

            builder.put("41", orgId);
            String multiValueByLimit = ParameterController.instance().getMultiValueByLimit(propertyCode, null, builder.build());
            basePropertyConfig.setPropertyCode(propertyCode);
            basePropertyConfig.setPropertyData(multiValueByLimit);
            return basePropertyConfig;
        } catch (Exception e) {
            LOGGER.info("查询系统参数错误： " + e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取参数配置列表
     */
    @RpcService
    @RpcAccess(auth = false)
    public List<Parameter> queryAllPropertyConfigBBP(PropertyConfigRequest request) {
        List<Parameter> data = new ArrayList<>();
        if (StringUtils.isEmpty(request.getPropertyCode())) {
            //  String propertyConfig = getPropertyConfigByPropertyCodeBBP(request);
            ParameterEntity parameterEntity = new ParameterEntity();
            parameterEntity.setDefaultValue(null);
            data.add(parameterEntity);
            return data;
        }
        try {
            if (StringUtils.isNotEmpty(request.getModuleCode())) {
                Module module = ModuleController.instance().getModuleByCode(request.getModuleCode());
                return ParameterController.instance().queryByFunctionId(module.getId());
            }
            if (StringUtils.isNotEmpty(request.getOrgId())) {
                data.addAll(AppContextHolder.get().getBean(IParamConfigService.class).queryByOrgId(request.getOrgId()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }

    /**
     * 初始化参数配置
     *
     * @param
     * @throws ControllerException
     */
    @RpcService
    public void initBasePropertyConfigBBP() throws ControllerException {
        try {
            //获取系统模块名称和id
       /* HashMap<String, String> moduleMapList = new HashMap<>();
        JSONResponseBean softList = ServiceAdapter.invokeWithJsonBytes("bbp.module", "findSoft", JSONUtils.parse("{'pageNo': 1, 'pageSize': 20}", Map.class));
        List<LinkedHashMap<String,String>> body = ( ArrayList<LinkedHashMap<String,String>>)softList.getBody();
        for (LinkedHashMap<String,String> moduleMap:body){
            List<Map<String, Object>> modules = AppContextHolder.get().getBean(IModuleService.class).findBySoftId(moduleMap.get("id"), 768);
            if (CommonUtils.isNotEmpty(modules)){
                for (Map<String, Object> module:modules) {
                    moduleMapList.put((String) module.get("cd"),(String) module.get("id"));
                }
            }
        }*/
            BasePropertyConfig basePropertyConfig = null;
            Dictionary svrOpenDic = null;
            Dictionary svrPropertyDic = null;
            svrOpenDic = DictionaryController.instance().get("hcn.base.dictionary.HCN_svrItemCode");
            svrPropertyDic = DictionaryController.instance().get("hcn.base.dictionary.HCN_svrOpenProperty");
            List<DictionaryItem> svrOpenItems = svrOpenDic.getSlice(null, 0, null);
            List<DictionaryItem> propertyItems = svrPropertyDic.getSlice(null, 0, null);
            ServiceProperty serviceProperty;
            //遍历机构开通的服务代码
            for (DictionaryItem svrOpenItem : svrOpenItems) {
                //服务代码
                String svrOpenKey = svrOpenItem.getKey();
                //服务名称
                String svrOpenName = svrOpenItem.getText();
                for (DictionaryItem propertyItem : propertyItems) {
                    //系统参数代码
                    String propertyKey = propertyItem.getKey();
                    //系统参数值
                    String propertyValue = propertyItem.getText();
                    //若是系统参数代码前四位和服务代码一致
                    if (propertyKey.substring(0, 4).equals(svrOpenKey)) {
                        //获取该服务
                        Service service = serviceOpenIntf.getServiceByCode(svrOpenKey);
                        //若是服务不存在，就新增该服务
                        if (null == service) {
                            service = new Service();
                            service.setServiceId(UUID.randomUUID().toString());
                            service.setServiceType(svrOpenKey.substring(0, 2));
                            service.setServiceCode(svrOpenKey);
                            service.setServiceName(svrOpenName);
                            service.setServiceDesc(svrOpenName);
                            service.setServiceGuide(svrOpenName);
                            service.setOrgServiceFlag("1");
                            service.setServicePaytype("1");
                            service.setDeptServiceFlag("0");
                            service.setDoctorServiceFlag("0");
                            service.setEffectiveFlag("1");
                            service.setServiceStackFlag("0");
                            service.setPlanFlag("0");
                            service.setUrgentFlag("0");
                            service.setUrgentFee(0D);
                            service.setCreateDt(new Timestamp(System.currentTimeMillis()));
                            service.setStartDt(new Timestamp(System.currentTimeMillis()));
                            serviceOpenIntf.saveService(service);
                        }
                        saveInitBasePropertyConfig(propertyKey, propertyValue);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * @description: 保存初始化的系统参数
     */
    public void saveInitBasePropertyConfig(String propertyKey, String propertyValue) throws Exception {

        HashMap<String, Object> map = new HashMap<>();
        map.put("cd", propertyKey);
        map.put("mnemonicCode", "");
        map.put("paramType", "02");  //参数类型  1 局部参数 2系统参数
        map.put("py", "");
        map.put("validEndTime", "");
        map.put("valueSource", "");
        map.put("valueSourceType", "4"); //参数值来源类型
        map.put("valueType", "1");  //参数数值类型  1字符 2数值
        map.put("validStartTime", new Date().toLocaleString());
        map.put("wb", "");
        map.put("zj", "");
        if (StringUtils.isNotEmpty(propertyValue)) {
            propertyValue = propertyValue.replaceAll(" ", "");
        }
        String danWei = "单位:";
        String unit = "";
        if (propertyValue.indexOf(danWei) > 0) {
            //将单位放入描述字段
            unit = propertyValue.substring(propertyValue.indexOf(danWei) + 3, propertyValue.lastIndexOf(")"));
            map.put("des", unit);
        }
        String na = "";
        if (propertyValue.indexOf("(") > -1 && propertyValue.indexOf(")") > -1) {
            na = propertyValue.substring(0, propertyValue.indexOf("("));
        } else {
            na = propertyValue;
        }
        if (na.length() > 20) {
            na = na.substring(0, 20);
        }
        map.put("na", na);
        map.put("defaultValue", propertyValue.substring(propertyValue.indexOf("默认:") + 3));
        ServiceAdapter.invokeWithJsonBytes("bbp.paramConfig", "saveParam", map, "00", "create");
    }

    /**
     * 获取参数配置列表
     *
     * @param objectId 来源id(租户id或机构id)
     * @return
     */
    @RpcService
    public List<BasePropertyConfig> queryAllPropertyConfig(String objectId, String moduleId, String propertyCode) throws Exception {
        List<BasePropertyConfig> result = new ArrayList<>();
        if (StringUtils.isNotEmpty(propertyCode)) {
            result.add(getPropertyConfigByPropertyCode(propertyCode, objectId));
            return result;
        }
        if (StringUtils.isNotEmpty(moduleId)) {
            result.addAll(queryPropertyConfigByModuleId(objectId, moduleId));
            return result;
        }

        List<Parameter> parameters = AppContextHolder.get().getBean(IParamConfigService.class).queryByOrgId(objectId);
        if (CommonUtils.isNotEmpty(parameters)) {
            for (Parameter parameter : parameters) {
                BasePropertyConfig basePropertyConfig = new BasePropertyConfig();
                basePropertyConfig.setPropertyCode(parameter.getCd());
                basePropertyConfig.setPropertyData(parameter.getDefaultValue());
                basePropertyConfig.setUnit(parameter.getDes());
                result.add(basePropertyConfig);
            }
            return result;
        }
        return null;
    }

    /**
     * 文案配置详情
     *
     * @param id 主键id
     * @return
     */
    @RpcService
    public BaseCopywriterConfig getCopywriterConfigDetail(int id) {
        BaseCopywriterConfig baseCopywriterConfig = baseCopywriterConfigDAO.getCopywriterConfigById(id);
        return baseCopywriterConfig;
    }

    /**
     * 文案配置详情 (APP)
     *
     * @param qo 主键copywriterCode
     * @param
     * @return
     */
    @RpcService
    public BaseCopywriterConfig getCopywriterByCode(CopywriterQo qo) {
        String token = UserRoleToken.getCurrentTenantId();
        BaseCopywriterConfig baseCopywriterConfig = new BaseCopywriterConfig();
        if (StringUtils.isNotEmpty(qo.getOrgId())) {
            baseCopywriterConfig = baseCopywriterConfigDAO.getCopywriterConfigByCode(qo.getConfigurationId(), qo.getOrgId());
            if (baseCopywriterConfig == null || StringUtils.isEmpty(baseCopywriterConfig.getContent())) {
                baseCopywriterConfig = baseCopywriterConfigDAO.getCopywriterConfigByCode(qo.getConfigurationId(), qo.getTenantId());
            }
        } else {
            baseCopywriterConfig = baseCopywriterConfigDAO.getCopywriterConfigByCode(qo.getConfigurationId(), qo.getTenantId());
        }
        return baseCopywriterConfig;
    }


    /**
     * 获取文案配置列表
     *
     * @param objectId 来源id(租户id或机构id)
     * @return
     */
    @RpcService
    public List<BaseCopywriterConfig> queryAllCopywriterConfig(String objectId, String moduleId) {
        List<BaseCopywriterConfig> list = new ArrayList<BaseCopywriterConfig>();
        if (StringUtils.isNotEmpty(moduleId)) {
            list = baseCopywriterConfigDAO.queryCopywriterConfigByParams(moduleId, objectId);
        } else {
            list = baseCopywriterConfigDAO.queryCopywriterConfigByParams(null, objectId);
        }
        return list;
    }

    /**
     * 获取功能配置菜单
     *
     * @return
     */
    @RpcService
    public List<ModuleConfigVo> queryModuleMenuList() throws ControllerException {
        List<ModuleConfigVo> list = new ArrayList<ModuleConfigVo>();
        ModuleConfigVo moduleConfigVo = new ModuleConfigVo();
        moduleConfigVo.setTenantId(RpcUserToken.getTenantId());
        moduleConfigVo.setTenantName("健康城市");
        List<OrgBean> orgBeanList = organizationInfoIntf.queryOrgInfoByTenantId(RpcUserToken.getTenantId());
        moduleConfigVo.setOrgBeanList(orgBeanList);
        list.add(moduleConfigVo);
        return list;
    }

    /**
     * 文案配置详情
     *
     * @param objectId
     * @return
     */
    @RpcService
    public BaseCopywriterConfig getCopywriterConfigByCopywriterCode(String copywriterCode, String objectId) {
        BaseCopywriterConfig baseCopywriterConfig = baseCopywriterConfigDAO.getCopywriterConfigByCode(copywriterCode, objectId);
        return baseCopywriterConfig;
    }

    @Override
    public BasePropertyConfig getPropertyConfigByPropertyCode(String propertyCode, String objectId) {
        try {
            BasePropertyConfig basePropertyConfig = new BasePropertyConfig();
            if (StringUtil.isEmpty(propertyCode)) {
                throw new ControllerException("系统参数编码不能为空");
            }
            Parameter parameter = null;
            if (StringUtils.isEmpty(objectId)) {
                parameter = ParameterController.instance().get(propertyCode, null);
                basePropertyConfig.setPropertyCode(propertyCode);
                basePropertyConfig.setPropertyData(parameter.getDefaultValue());
                basePropertyConfig.setUnit(parameter.getDes());
                return basePropertyConfig;
            }

            ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();

            //获取当前token所属的租户id
            String currentTenantId = UserRoleToken.getCurrentTenantId();
            if (objectId.equals(currentTenantId)) {
                //租户id
                builder.put("1", objectId);
            } else {
                builder.put("41", objectId);
            }

            String multiValueByLimit = ParameterController.instance().getMultiValueByLimit(propertyCode, null, builder.build());
            basePropertyConfig.setPropertyCode(propertyCode);
            basePropertyConfig.setPropertyData(multiValueByLimit);
            return basePropertyConfig;
        } catch (Exception e) {
            LOGGER.info("查询系统参数错误： " + e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<BasePropertyConfig> queryPropertyConfigList(String objectId, List<String> propertyCodes) throws ControllerException {

        ArrayList<BasePropertyConfig> propertyList = new ArrayList<>();
        if (CommonUtils.isEmpty(propertyCodes)) {
            throw new ControllerException("系统参数编码集不能为空");
        }
        for (String propertyCode : propertyCodes) {
            BasePropertyConfig basePropertyConfig = getPropertyConfigByPropertyCode(propertyCode, objectId);
            propertyList.add(basePropertyConfig);
        }
        return propertyList;
    }

    @Override
    public List<BasePropertyConfig> queryPropertyConfigByModuleId(String objectId, String moduleId) throws Exception {
        PropertyCodeDTO propertyCodeDTO = PropertyCodeDTO.builder().propertyCode(moduleId).functionId(golAppCode).build();
        ObjectIdDTO objectIdDTO = ObjectIdDTO.builder().objectId(objectId).build();
        List<ParameterVO> params = ParamUtils.getParamsByModuleId(propertyCodeDTO, objectIdDTO);
        if (CommonUtils.isEmpty(params)) {
            return Collections.emptyList();
        }
        return params.stream().map(p -> {
            BasePropertyConfig config = new BasePropertyConfig();
            config.setPropertyCode(p.getCode());
            config.setPropertyData(p.getValue());
            config.setUnit(p.getDes());
            return config;
        }).collect(Collectors.toList());
    }


}

